package spring.ioc;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.config.ContextNamespaceHandler;
import org.springframework.stereotype.Service;

public class MyAnnotationBeanDefinitionLoad {
    
    // spring 
    private static ContextNamespaceHandler contextNamespaceHandler = new ContextNamespaceHandler();
//    private static ComponentScanBeanDefinitionParser componentScanBeanDefinitionParser = new ComponentScanBeanDefinitionParser();

    // bean的Definition的注册器
    private static  BeanDefinitionRegistry registry = new AnnotationConfigApplicationContext("spring.ioc.annotation.service");

    // bean的definition的读取器,将bean的definition读取到注册器中
    private static AnnotatedBeanDefinitionReader beanDefinitionReader = new AnnotatedBeanDefinitionReader(registry);

    public static void main(String[] args) {
        contextNamespaceHandler.init();
        
//        Resource resource = new ClassPathResource("application.xml");
//        AnnotationBeanNameGenerator annotationBeanFactory;
        
        beanDefinitionReader.register(Service.class);
//        Resource resource = 
        
        // 根据目标资源，获取xml中各个bean的definition内容，并且将definition注册到BeanDefinitionRegistry中
//        int result = beanDefinitionReader.loadBeanDefinitions(resource);

//        System.out.println(result);
    }
    
}
